<template>
	<view class="index">
		<view class="bjImage">
			<image src="@/static/my/bg.png" mode=""></image>
		</view>
		<view class="infoBox">
			<view class="info_b">
				<view class="member_l" @tap.stop="Jump('/pages/home/bookDetails')">
					<image class="image" src="@/static/my/left.png" mode=""></image>
					<view class="text">公司简介</view>
				</view>
				<view class="line"></view>
				<view class="member_l" @tap.stop="Jump('/pages/home/activityDetail')">
					<image class="image" src="@/static/my/center.png" mode=""></image>
					<view class="text">入市用户名录</view>
				</view>
				<view class="line"></view>
				<view class="member_l" @tap.stop="toPdf">
					<image class="image" src="@/static/my/right.png" mode=""></image>
					<view class="text">用户用电</view>
				</view>
			</view>
		</view>
		<!-- 基础知识-->
		<venue ref="venue" />
		<!-- 相关政策 -->
		<swiming ref="swiming" />
		<!-- 读好书 -->
		<!-- <reading ref="reading" /> -->
		<!-- 看直播 -->
		<!-- <liveStreaming ref="liveStreaming" /> -->
		<!-- 相关视频 -->
		<heritage ref="heritage" />
	</view>

</template>

<script>
	import swiming from '@/pages/index/swiming.vue';
	import venue from '@/pages/index/venue.vue';
	// import reading from '@/pages/index/reading.vue';
	// import liveStreaming from '@/pages/index/liveStreaming.vue';
	import heritage from '@/pages/index/heritage.vue';

	import {
		newsList,
		newsCategory,
		electricity
	} from "@/request/homeApi.js";
	import brl from "@/request/baseUrl.js"
	export default {
		components: {
			venue,
			// reading,
			// liveStreaming,
			heritage,
			swiming
		},
		data() {
			return {
				pdfUrl: ''
			}
		},
		onShow() {
			setTimeout(() => {
				this.$refs.swiming.getList()
				this.$refs.venue.getList()
				this.$refs.heritage.getList()
				// this.$refs.liveStreaming.getCategory()

			}, 1000)

		},


		methods: {
			toPdf() {
				electricity().then(res => {
					if (res.code == 200) {
						if (res.data[0].value != null && res.data[0].value != '') {
							this.pdfUrl = brl.baseUrl + res.data[0].value
							setTimeout(() => {
								uni.getSystemInfo({
									success: res => {
										console.log(this.pdfUrl, 'this.pdfUrl');
										wx.downloadFile({
											url: this.pdfUrl,
											// filePath: wx.env.USER_DATA_PATH + '/1.pdf',
											success: function(res) {
												wx.openDocument({
													showMenu: true,
													filePath: res.tempFilePath,
													success: function(
													res) {
														console.log(
															'打开文档成功'
															);
													}
												});
											}
										});
									}
								});
							}, 1000)
						} else {
							uni.showToast({
								title: '暂无',
								duration: 1500,
								icon: 'none',
							})
						}

					} else {
						uni.showToast({
							title: res.msg,
							duration: 1500,
							icon: 'none',
						})
					}
				})


				// uni.navigateTo({
				// 	url:`/pages/my/pdf?type=2`
				// })
			},
			Jump(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	.index {
		width: 100vw;

		.bjImage {
			width: 100%;

			image {
				width: 100%;
			}
		}

		.infoBox {
			width: 90%;
			height: 174rpx;
			border-radius: 20rpx;
			background: #FFFFFF;
			backdrop-filter: blur(10px);
			margin: 0 auto;
			margin-top: -88rpx;
			padding: 30rpx;
			box-sizing: border-box;

			.info_b {
				display: flex;
				text-align: center;
				height: 100%;
				font-size: 28rpx;

				.member_l {
					width: 33%;
					display: flex;
					flex-wrap: wrap;
					flex-direction: column;
					color: #313131;
					justify-content: space-between;
					text-align: center;

					.image {
						margin: 0 auto;
						width: 68rpx;
						height: 68rpx;
					}

					.text {
						color: #000;

					}
				}
			}

		}
	}
</style>